package com.example.demo02;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;

@Component
public class Listener implements ApplicationListener<Event> {

    private static final Logger logger = LoggerFactory.getLogger(Listener.class);

    @Override
    public void onApplicationEvent(Event event) {
        logger.info("Listener get event，sleep 2 second...");
        try {
            Thread.sleep(2000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        logger.info("event's message is : {}", event.getMessage());
    }

}
